import { testSort } from "./utils";

function bubbleSort(arr: number[]): number[] {
  const n = arr.length;
  for (let j = 0; j < n; j++) {
    for (let i = 0; i < n - 1 - j; i++) {
      if (arr[i] > arr[i + 1]) {
        [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
      }
    }
  }

  return arr;
}

//test代码
testSort(bubbleSort);
